package com.fanbuchi.app.ins.utils;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Created by win7 on 2016/5/27.
 */
public class Md5Utils {


    public static String getmd5(String salt,String pass) {
        byte[] hash;
        try {
            hash = MessageDigest.getInstance("MD5").digest((salt+pass+salt).getBytes("UTF-8"));
        } catch (NoSuchAlgorithmException e) {
            return  null;
        } catch (UnsupportedEncodingException e) {
            return  null;
        }

        StringBuilder hex = new StringBuilder(hash.length * 2);
        for (byte b : hash) {
            if ((b & 0xFF) < 0x10) hex.append("0");
            hex.append(Integer.toHexString(b & 0xFF));
        }
        return hex.toString();
    }
}
